@extends('layouts.app')
@include('system.sidebar')
@section('content')
    <div class="content">
        <a class="btn btn-info btn-sm" href="{{ redirect()->back()->getTargetUrl() }}"> 返回 </a>
        <br />
        <br />
        {!! form($form) !!}
    </div>
@endsection
@push("stylesheets")
    <style>
        .select2-container--default .select2-selection--multiple .select2-selection__choice {
            color: gray;
        }
    </style>
@endpush
@push("scripts")
    <script>
        // 按照客户要求, 修改表单样式
        // 表单通过后台生成, 所以通过js调整样式
        var _form_type = "{{isset($flag) ? $flag : ''}}";
        if (_form_type == 'banner') {
            $('.content').find('form').addClass('form-inline')
            $('.content').find('form').find('label').attr('style', 'width:120px;text-align:center')
            $('.form-group').attr('style', 'margin:10px 0px;')

            $('[for="image"]').next('div').attr('style', 'display:inline')
            $('[for="image"]').parent().find('br').remove();
            $('[for="image"]').parent().find('p').attr('style', 'margin-left:10px;display:inline');
            $('[for="image"]').parent().find('p').after('<br>');
            $('[for="image"]').parent().after('<br>');

            $('[for="aim"]').parent().after('<br>');
            $('[for="shop_id"]').parent().after('<br>');
            $('[for="link_id"]').parent().find('p').attr('style', 'display:inline')
            $('[for="link_id"]').parent().after('<br>');
            $('[for="url"]').parent().after('<br>');
            $('[for="sort"]').parent().after('<br>');
        } else if (_form_type == 'page') {
            $('.content').find('form').addClass('form-inline')
            $('.content').find('form').find('label').attr('style', 'width:100px;text-align:center')
            $('.form-group').attr('style', 'margin:10px 0px;')

            $('[for="can_apply_partner"]').parent().after('<br>');
            $('[for="can_apply_partner"]').attr('style', 'width:150px;text-align:center');
            $('[for="customer_service_mobile"]').parent().after('<br>');

            $('[for="customer_service_qr_code"]').next('div').attr('style', 'display:inline')
            $('[for="customer_service_qr_code"]').parent().find('br').remove();
            $('[for="customer_service_qr_code"]').parent().find('p').attr('style', 'margin-left:10px;display:inline');
            $('[for="customer_service_qr_code"]').parent().find('span').after('<br>');
            $('[for="customer_service_qr_code"]').parent().after('<br>');

            $('[for="share_image"]').next('div').attr('style', 'display:inline')
            $('[for="share_image"]').parent().find('br').remove();
            $('[for="share_image"]').parent().find('p').attr('style', 'margin-left:10px;display:inline');
            $('[for="share_image"]').parent().find('span').after('<br>');
            $('[for="share_image"]').parent().after('<br>');

            $('[for="partner_bg"]').next('div').attr('style', 'display:inline')
            $('[for="partner_bg"]').parent().find('br').remove();
            $('[for="partner_bg"]').parent().find('p').attr('style', 'margin-left:10px;display:inline');
            $('[for="partner_bg"]').parent().find('span').after('<br>');
            $('[for="partner_bg"]').parent().after('<br>');

            $('[for="rule_video"]').next('div').attr('style', 'display:inline')
            $('[for="rule_video"]').parent().find('br').remove();
            $('[for="rule_video"]').parent().find('p').attr('style', 'margin-left:10px;display:inline');
            $('[for="rule_video"]').parent().find('span').after('<br>');
            $('[for="rule_video"]').parent().after('<br>');

        }

        tinymce.init({
            selector: '#editor, #editor1',
            plugins: "textcolor colorpicker uploadimage autoresize",
            menubar: false,
            toolbar: "uploadimage undo redo | fontsizeselect bold italic forecolor backcolor | alignleft aligncenter alignright alignjustify",
            images_upload_url: '/admin/upload_image?_token=' + $('meta[name="csrf-token"]').attr('content'),
            images_upload_credentials: true,
            image_dimensions: false,
            image_caption: false,
            image_description: false,
            language: 'zh_CN',
            language_url : '/tinymce/langs/zh_CN.js',
            autoresize_min_height: 350,
            autoresize_max_height: 800,
            content_style: 'img {width: 100%; height: auto; vertical-align: middle;}',
            init_instance_callback: function (editor) {
                editor.on('change', function (e) {
                    editor.save();
                });
            }
        });

        $('#link_id').attr('style', 'width:500px;')
    </script>
@endpush
